<?php
/**
 * @version        $Id$
 * @author         master@xuewl.com
 * @copyright      Copyright (c) 2007 - 2013, Chongqing Zero Technology Co. Ltd.
 * @link           http://www.xuewl.com
**/
class SmsHook {
	/* 领取返利券时 */
    public function member_rebate_action(&$param) {
    	extract($param);
        $mobile = getUserInfo($uid, 'phone');
        if(empty($mobile)) return FALSE;
        $message = ('您的返利券验证码为：'.$vcode);
        $SmsApi = new \Sms\Api\SmsApi();
        $SmsApi->send($mobile, $message);
    }

    /* 验证返利券 */
    public function member_rebate_validate(&$param) {
    	extract($param);
    	$channel_name = D('MemberRebateChannel')->getFieldByChannelid($channelid, 'channelname');
    	$validate = dgmdate(NOW_TIME, 'Y年m月d日');
        $mobile = getUserInfo($uid, 'phone');
        if(empty($mobile)) return FALSE;
        $message = '您的返利券「'.$vcode.'」于'.$validate.'在『'.$channel_name.'』已验证使用！';
        $SmsApi = new \Sms\Api\SmsApi();
        $SmsApi->send($mobile, $message);	
    }

    /* 返利时通知 */
    public function member_rebate_finish(&$param) {
    	extract($param);
    	$channel_name = D('MemberRebateChannel')->getFieldByChannelid($channelid, 'channelname');
    	$validate = dgmdate(NOW_TIME, 'Y年m月d日');
        $mobile = getUserInfo($uid, 'phone');
        if(empty($mobile)) return FALSE;
        $message = '您在『'.$channel_name.'』验证的返利券「'.$vcode.'」于'.$validate.'已返利！';
        $SmsApi = new \Sms\Api\SmsApi();
        $SmsApi->send($mobile, $message);
    }
}